
import React from "react";
import {Form,Input} from "antd";
import {diffProps} from "../../libs/funcs";

/**
 * 输入框
 */
class FormInput extends React.Component{

    constructor(props) {
        super(props);
        this.state={}
    }

    render() {
        const {getFieldDecorator} =  this.props.form;
        const {initialValue,label,field,rules,allowClear,placeholder,disabled,addonAfter,addonBefore} = this.props;
        const new_props = diffProps(this.props,["form","initialValue","label","field","rules","allowClear","placeholder"]);

        return (
            <Form.Item label={label ? label : "输入框"} {...new_props}>
                {getFieldDecorator(field ? field : "default_input", {initialValue: initialValue,rules: rules ? rules : []})(
                    <Input
                        allowClear={allowClear ? allowClear : false}
                        placeholder={placeholder ? placeholder: "请输入..."}
                        {...(disabled ? { disabled: true } : {})}
                        addonAfter={addonAfter}
                        addonBefore={addonBefore}
                    />
                )}
            </Form.Item>
        );
    }
}

export default FormInput;
